package yjpay.api.web.control;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import yjpay.service.PayAPIService;

/**
 * 调用支付API根据用户身份标识获取绑卡列表接口示例
 * @author junqinghuang
 * @date 2013-8-14
 */
@Controller
public class BindListWebCtrl {

	@Resource(name = "payAPIService")
	private PayAPIService payAPIService;
	
	@RequestMapping(value = "/pay/to_bindlist")
	public ModelAndView home(HttpServletRequest request) {
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("pay/bindlist.jsp");
		return modelAndView;
	}
	
	
	@RequestMapping(value = "/pay/bindlist")
	public ModelAndView biandpay(Model model,
			@RequestParam("identityid") String  identityid,
			@RequestParam("identitytype") int identitytype,
			HttpServletRequest request) throws Exception {

		String payresult = payAPIService.bindList(identityid, identitytype);

		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("pay/pay_result.jsp");
		modelAndView.addObject("apiname", "绑卡关系列表接口");
		modelAndView.addObject("payresult_view", payresult);

		return modelAndView;
	}
	
}
